package com.sj.moveStop;

/**
 * move()和stop()中两段代码几乎一样，
 * 将它们封装起来，比如beforeMethod(), afterMethod()
 */
public class TankTimeProxy implements IMoveable {

    private IMoveable t;

    public TankTimeProxy(IMoveable t) {
        super();
        this.t = t;
    }

    public void move() {
        long start = System.currentTimeMillis();
        System.out.println("starttime: " + start);
        t.move();
        long end = System.currentTimeMillis();
        System.out.println("time: " + (end - start));
    }

    public void stop() {
        long start = System.currentTimeMillis();
        System.out.println("starttime: " + start);
        t.stop();
        long end = System.currentTimeMillis();
        System.out.println("time: " + (end - start));
    }
}
